import {getMultiScreenOfLcd} from 'share/server/utils.js'

export function devsOfLcd (state) {
  return state.devmng.topoSummary.list.filter((item) => {
    return item.devModel.includes('lcd')
  })
}

export function currLcdInfo (state) {
  var lcdInfo = {}
  let lcd = state.lcd
  let topoDev = lcd.topoDev
  if (lcd.virtualTopoId > 0) {
    let mode = lcd.modes[lcd.modeId - 1]
    let area = _.find(mode.areas, {virtualTopoId: lcd.virtualTopoId})
    lcdInfo.topoId = lcd.virtualTopoId
    lcdInfo.multiScreenX = area.multiScreenX
    lcdInfo.multiScreenY = area.multiScreenY
    lcdInfo.name = topoDev.devName + '-' + mode.name + '-' + area.name
  } else {
    let multiScreen = getMultiScreenOfLcd(topoDev.devModel)
    lcdInfo.topoId = topoDev.topoId
    lcdInfo.multiScreenX = multiScreen.x
    lcdInfo.multiScreenY = multiScreen.y
    lcdInfo.name = topoDev.devName
  }

  return lcdInfo  
}